package com.geekca.d8;

import java.util.Scanner;

public class Login {
    public static void main(String[] args) {
        String username = "zhangsan";
        String password = "12365";

        Scanner scanner = new Scanner(System.in);

        int i = 0;
        while (true) {
            if (i >= 3) {
                System.out.println("连续输入错误超过三次,程序退出!");
                break;
            }
            System.out.println("请输入用户名");
            String inputUser = scanner.next();

            System.out.println("请输入密码");
            String inputPass = scanner.next();
            if (inputPass.equals(password) && inputUser.equals(username)) {
                System.out.println("登录成功!");
                break;
            } else {
                System.out.println("用户名或密码错误,请重新登录");
            }
            i += 1;
        }
    }
}
